package stateframework_particle.view;

import particle.core.controller.ControllerEvent;
import particle.core.view.View;
import state.GameGlobal;
import state.Midlet;
import stateframework_particle.view.controls.StateFramework_ParticlePanel;

public class StateFramework_ParticleView extends View {
  public StateFramework_ParticlePanel m_mainPanel = null;

  public StateFramework_ParticleView() {
  }

  protected void onDestroy() {
    if (null != m_mainPanel) {
      m_mainPanel.destroy();
      m_mainPanel = null;
    }
  }
  
  public void onControllerEvent(ControllerEvent p_event) {
    switch (p_event.id) {
    case ControllerEvent.Start:
      m_mainPanel = new StateFramework_ParticlePanel();
      m_mainPanel.create();
      Midlet midlet = new Midlet();
      midlet.startApp(this, m_mainPanel);
      GameGlobal.systemCanvas.setControlData(m_mainPanel.getControlData());
      addTopLevelControl(m_mainPanel);
      m_mainPanel.show();
      break;
    default:
      super.onControllerEvent(p_event);
    }
  }
}